-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle multiple function calls in openai #346
Conversation
…nly one function call at a time. Fixed this to handle multiple function calls.
This is awesome. Thank you! @chadbailey59 what do you think? |
Great thanks! |
any concerns merging this? I'm running into the same error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Just needs one tiny fix.
src/pipecat/services/openai.py
Outdated
tool_id_list.append(tool_call_id) | ||
for function_name,arguments,tool_id in zip(functions_list,arguments_list,tool_id_list): | ||
if self.has_function(function_name): | ||
await self._handle_function_call(context, tool_call_id, function_name, arguments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument here should be tool_id
not tool_call_id
.
Oof. Enough stuff has changed out from under this PR that there needs to be some more code in the context aggregator to make this work, now. I'll figure this out tonight and post another PR. Thank you for doing the work, here ... we'll get this into the next Pipecat release! |
Merged as this PR: #522 |
openai can give multiple tool calls
ex : "message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_cuC7cq3IoIqCN2IvwfGuNl8J",
"type": "function",
"function": {
"name": "add_numbers",
"arguments": "{"a": 1, "b": 2}"
}
},
{
"id": "call_SfbHakQINYSeK9a7VzQq50OW",
"type": "function",
"function": {
"name": "add_numbers",
"arguments": "{"a": 3, "b": 4}"
}
}
],
"refusal": null
},
The current implementation assumes only single function call. In this case we get function name as add_numbersadd_numbers (here we have function name twice ). This would fail when the openai is giving multiple tool calls.
The fix I used is create a list of function names and call them.